package demo1;

//牛客网:打怪
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- > 0) {
            int h1 = in.nextInt(); //血量 5 
            int a1 = in.nextInt(); //攻击力 1
            int h2 = in.nextInt(); //血量 2 
            int a2 = in.nextInt(); //攻击力 1
            if (a2 == 0 || h2 == 0 || h2 - a1 <= 0) {
                System.out.println(-1);
            }else {
                int x = 0;
                int h = h2;
                while (h1 > 0) {
                    h2 -= a1;
                    if (h2 <= 0) {
                        x++;
                        h2 = h;
                    } else {
                        h1 -= a2;
                    }
                }
                System.out.println(x);
            }
        }
    }
}